Description

The followings show a simple example using Webwork's Non Field Validators

Step 1

Create the jsp page

<ww:actionerror />
	
<ww:form method="POST" action="submitNonFieldValidatorsExamples" namespace="/validation">
	<ww:textfield name="someText" label="Some Text" />
	<ww:textfield name="someTextRetype" label="Retype Some Text" />  
	<ww:textfield name="someTextRetypeAgain" label="Retype Some Text Again" />
	<ww:submit label="Submit" />
</ww:form>

Step 2

Create the action class

public class NonFieldValidatorsExampleAction extends AbstractValidationActionSupport {
	
	private String someText;
	private String someTextRetype;
	private String someTextRetypeAgain;
	
	public String getSomeText() {
		return someText;
	}
	public void setSomeText(String someText) {
		this.someText = someText;
	}
	public String getSomeTextRetype() {
		return someTextRetype;
	}
	public void setSomeTextRetype(String someTextRetype) {
		this.someTextRetype = someTextRetype;
	}
	public String getSomeTextRetypeAgain() {
		return someTextRetypeAgain;
	}
	public void setSomeTextRetypeAgain(String someTextRetypeAgain) {
		this.someTextRetypeAgain = someTextRetypeAgain;
	}
}

Step 3

Create the validator.xml.

<validators>
	<validator type="expression">
		<param name="expression"><![CDATA[ ( (someText == someTextRetype) && (someTextRetype == someTextRetypeAgain) ) ]]></param>
		<message><![CDATA[ all three text must be exactly the same ]]></message>
	</validator>
</validators>